<template>
    <div class="Category">
      <List :typeId="type_id" :type="type" @index="index" class="List"/>
      <category-content class="Right"/>
    </div>
</template>

<script>
  import List from "../components/List";
  import CategoryContent from "../components/CategoryContent";

  import { apitypeall } from "../request/api"
  export default {
    name: "Category",
    data() {
      return {
        type_id: 0,
        type: []
      }
    },
    components: {
      List,
      CategoryContent
    },
    methods: {
      index(x){
        this.type_id = x
        this.$bus.emit("aMsg", x);
        // console.log(x)
      }
    },
    activated () {
      this.type_id = this.$route.query.type_id-1;

      this.$bus.emit("aMsg", this.$route.query.type_id-1);

      apitypeall({}).then(res => {
        this.type = res.data.type;
      });
    }
  }
</script>

<style scoped>
  .Category {
    margin: 10px 0 100px;
    display: flex;
    flex-direction: row;
  }
  .List {
    width: 25%;
  }
  .Right {
    width: 75%;
    margin-left: 6%;
  }

</style>
